package com.jorado.redis;

import redis.clients.jedis.JedisCluster;

import java.io.Closeable;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 *
 */
public interface RedisClientInterface extends Closeable {
    // cpu的核数
    int CPU_COUNT = Runtime.getRuntime().availableProcessors();
    // redis默认端口
    int DEFAULT_REDIS_PORT = 6379;
    // 最大重试次数
    int DEFAULT_MAX_REDIRECTIONS = 2;
    // 默认的连接超时时间
    int DEFAULT_CONNECT_TIMEOUT = 200;
    // 默认的读取超时时间
    int DEFAULT_SOCKET_TIMEOUT = 500;
    // 从连接池中获取连接的最大等待时间(毫秒为单位)
    int DEFAULT_MAX_WAIT_MILLIS = 500;
    // 默认的熔断时间
    int DEFAULT_FUSE_MILLIS = 5000;
    // 连接池配置参数(最大的连接数)
    int DEFAULT_MAX_TOTAL = CPU_COUNT * 2;
    // 连接池配置参数(最大空闲连接)
    int DEFAULT_MAX_IDLE = CPU_COUNT * 2;
    // 连接池配置参数(最少空闲连接)
    int DEFAULT_MIN_IDLE = CPU_COUNT * 2;

    // 该方法不允许改名，否则会造成代理类有问题
    JedisCluster getRedisClient();

    //
    String set(final String key, final String value);

    //
    String set(final String key, final String value, final String nxxx, final String expx, final long time);

    //
    String set(final String key, final String value, final String expx, final long time);

    // 以秒为单位的超时时间设置key的过期(等同于setex命令)
    String setEx(String key, String value, int time);

    // 以毫秒为单位的超时时间设置key的过期(等同于psetex命令)
    String pSetEx(String key, String value, long time);

    Long del(String key);

    Boolean exists(String key);

    Long expire(final String key, final int seconds);

    Long expireAt(final String key, final long unixTime);

    Long persist(final String key);

    Long pexpire(final String key, final long milliseconds);

    Long pexpireAt(final String key, final long millisecondsTimestamp);

    Long ttl(final String key);

    String type(final String key);

    String get(final String key);

    Long incr(final String key);

    Long incrBy(final String key, final long integer);

    Long setnx(final String key, final String value);

    String setex(final String key, final int seconds, final String value);

    Long decr(final String key);

    Long decrBy(final String key, final long integer);

    String getSet(final String key, final String value);

    Long hdel(final String key, final String... field);

    Boolean hexists(final String key, final String field);

    String hget(final String key, final String field);

    Map<String, String> hgetAll(final String key);

    Long hincrBy(final String key, final String field, final long value);

    Set<String> hkeys(final String key);

    Long hlen(final String key);

    String hmset(final String key, final Map<String, String> hash);

    List<String> hmget(final String key, final String... fields);

    Long hset(final String key, final String field, final String value);

    Long hsetnx(final String key, final String field, final String value);

    List<String> hvals(final String key);

    String lindex(final String key, final long index);

    Long llen(final String key);

    String lpop(final String key);

    List<String> blpop(final int timeout, final String key);

    List<String> brpop(final int timeout, final String key);

    Long lpush(final String key, final String... string);

    Long lpushx(final String key, final String... string);

    List<String> lrange(final String key, final long start, final long end);

    Long lrem(final String key, final long count, final String value);

    String lset(final String key, final long index, final String value);

    String ltrim(final String key, final long start, final long end);

    String rpop(final String key);

    Long rpush(final String key, final String... string);

    Long rpushx(final String key, final String... string);

    Long sadd(final String key, final String... member);

    Long scard(final String key);

    Boolean sismember(final String key, final String member);

    Set<String> smembers(final String key);

    String spop(final String key);

    Set<String> spop(final String key, final long count);

    String srandmember(final String key);

    Long srem(final String key, final String... member);

    Long zadd(final String key, final Map<String, Double> scoreMembers);

    Long zadd(final String key, final double score, final String member);

    Long zcard(final String key);

    Long zcount(final String key, final String min, final String max);

    Long zcount(final String key, final double min, final double max);

    Double zincrby(final String key, final double score, final String member);

    Set<String> zrange(final String key, final long start, final long end);

    Set<String> zrangeByScore(final String key, final String min, final String max);

    Set<String> zrangeByScore(final String key, final double min, final double max);

    Long zrank(final String key, final String member);

    Long zrem(final String key, final String... member);

    Long zremrangeByRank(final String key, final long start, final long end);

    Long zremrangeByScore(final String key, final double start, final double end);

    Set<String> zrevrange(final String key, final long start, final long end);

    Set<String> zrevrangeByScore(final String key, final String max, final String min);

    Set<String> zrevrangeByScore(final String key, final double max, final double min);

    Long zrevrank(final String key, final String member);

    Double zscore(final String key, final String member);

    Object eval(final String script, final List<String> keys, final List<String> args);

    Long lbeforeinsert(final String key, final String pivot, final String value);

    Long lafterinsert(final String key, final String pivot, final String value);
}
